const express = require("express");
const app = express();
const HomeRouter = require("./Router/user/index");
const bodyParser = require("body-parser");
const IP = require("ip");
const port = 4000;

const ip = IP.address();
const travelRouter = require("./Router/travel/home");
const hotelRouter = require("./Router/hotel/index");
const foodsRouter = require("./Router/foods/index");
const strategyRouter = require("./Router/strategy/index");
const category = require("./Router/category/index");
const cors = require("cors");

// 允许跨域
app.use(cors());

app.use(
  bodyParser.urlencoded({
    extended: false,
  })
);

app.use(bodyParser.json());
// 测试接口
app.get("/", (req, res) => {
  res.send({
    code: 0,
    msg: "测试成功",
  });
});

// 用户相关信息
app.use("/user", HomeRouter);

// 旅游相关信息
app.use("/travel", travelRouter);
// 分类大全(含旅游,酒店,美食,攻略)
app.use("/category", category);
// 酒店相关信息
app.use("/hotel", hotelRouter);
// 美食相关查询
app.use("/foods", foodsRouter);
// 攻略相关查询
app.use("/strategy", strategyRouter);

app.listen(port, () => {
  console.log(`http://${ip}:${port}`);
  console.log("服务启动成功");
});
